package com.ss.tmall.service.impl;

import com.ss.tmall.mapper.UserMapper;
import com.ss.tmall.pojo.User;
import com.ss.tmall.pojo.UserExample;
import com.ss.tmall.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: ShengShuai
 * @Description:
 * @Date: Created in 下午 21:21  2017/12/27 0027
 * @Modified By:
 */
@Service
public class UserServiceImpl implements UserService{
    @Autowired
    UserMapper userMapper;
    @Override
    public  void  add(User user){
        userMapper.insert(user);
    }
    @Override
    public  void  delete(int id){
        userMapper.deleteByPrimaryKey(id);
    }
    @Override
    public  void  update(User user){
        userMapper.updateByPrimaryKeySelective(user);
    }
    @Override
    public  User get(int id){
       return userMapper.selectByPrimaryKey(id);
    }
    @Override
    public List<User> list(){
        UserExample example = new UserExample();
        example.setOrderByClause("id desc");
        return  userMapper.selectByExample(example);
    }
}
